package logic

import (
	"context"
	"homes/models/mysql"

	"homes/homerpc/homerpc"
	"homes/homerpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseShowLogic {
	return &HouseShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HouseShowLogic) HouseShow(in *homerpc.HouseShowRequest) (*homerpc.HouseShowResponse, error) {
	// todo: add your logic here and delete this line

	var house mysql.House
	mysql.DB.Debug().Where("id=?", in.Id).Find(&house)
	return &homerpc.HouseShowResponse{
		Id:        int64(house.ID),
		Address:   house.Address,
		HouseName: house.HouseName,
		Price:     float32(house.Price),
		Status:    house.Status,
	}, nil
}
